class WelcomeController < ApplicationController
  def index
    if (params[:search2] != nil)
      @value_con = params[:search1]
      @value_search = params[:search2]
      if(params[:search1] == "1")
        @books = Book.find(:all, :conditions => ['title LIKE ?', '%'+params[:search2]+'%' ])
      elsif (params[:search1] == "2")
        @books = Book.find(:all, :conditions => ['author LIKE ?', '%'+params[:search2]+'%' ])
      elsif (params[:search1] == "3")
        @books = Book.find(:all, :conditions => ['publisher LIKE ?', '%'+params[:search2]+'%' ])
      elsif (params[:search1] == "4")
        @books = Book.find(:all, :conditions => ['category LIKE ?', '%'+params[:search2]+'%' ])
      end
    else
      @books = Book.all
      @value_search = t("keyword")
      @value_con = "1"
    end
    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @books }
    end
  end

  def show
  end

  def error
  end
end
